var express = require('express');
var router = express.Router();
var connection = require('../db/sql.js')

/* GET home page. */
router.get('/', function(req, res, next) {
	res.render('index', {
		title: 'Express'
	});
});

// 首页数据
router.get("/api/index_list/data", function(req, res, next) {
	res.send({
		"code": 0,
		"data": {
			topBar: [{
					id: 1,
					name: "推荐"
				},
				{
					id: 2,
					name: "运动户外"
				},
				{
					id: 3,
					name: "服饰内衣"
				},
				{
					id: 4,
					name: "鞋靴箱包"
				},
				{
					id: 5,
					name: "美妆个护"
				},
				{
					id: 6,
					name: "家具数码"
				},
				{
					id: 7,
					name: "食品母婴"
				},
			],
			data: [{
					type: "swiperList",
					data: [{
							imgUrl: "/static/img/swiper1.jpg"
						},
						{
							imgUrl: "/static/img/swiper2.jpg"
						},
						{
							imgUrl: "/static/img/swiper3.jpg"
						}
					]
				},
				{
					type: "recommendList",
					data: [{
							bigUrl: "/static/img/swiper1.jpg",
							smallUrls: [{
									imgUrl: "/static/img/product1.jpg"
								},
								{
									imgUrl: "/static/img/product2.jpg"
								},
								{
									imgUrl: "/static/img/product3.jpg"
								}
							]
						},
						{
							bigUrl: "/static/img/swiper2.jpg",
							smallUrls: [{
									imgUrl: "/static/img/product4.jpg"
								},
								{
									imgUrl: "/static/img/product5.jpg"
								},
								{
									imgUrl: "/static/img/product6.jpg"
								}
							]
						},
						{
							bigUrl: "/static/img/swiper3.jpg",
							smallUrls: [{
									imgUrl: "/static/img/product1.jpg"
								},
								{
									imgUrl: "/static/img/product3.jpg"
								},
								{
									imgUrl: "/static/img/product5.jpg"
								}
							]
						},
						{
							bigUrl: "/static/img/swiper1.jpg",
							smallUrls: [{
									imgUrl: "/static/img/product2.jpg"
								},
								{
									imgUrl: "/static/img/product4.jpg"
								},
								{
									imgUrl: "/static/img/product6.jpg"
								}
							]
						},
					]
				},
				{
					type: "commodityList",
					data: [{
							id: 1,
							imgUrl: "/static/img/product2.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "29.9元",
							oprice: "59.9元",
							discount: "4.99折"
						},
						{
							id: 2,
							imgUrl: "/static/img/product1.jpg",
							name: "毛绒大衣爆款2022必备不买血亏",
							pprice: "26.9元",
							oprice: "98.9元",
							discount: "3.8折"
						},
						{
							id: 3,
							imgUrl: "/static/img/product3.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "299.9元",
							oprice: "599.9元",
							discount: "2.7折"
						},
						{
							id: 4,
							imgUrl: "/static/img/product4.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "129.9元",
							oprice: "159.9元",
							discount: "8.8折"
						},
						{
							id: 5,
							imgUrl: "/static/img/product5.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "129.9元",
							oprice: "159.9元",
							discount: "8.8折"
						},
						{
							id: 6,
							imgUrl: "/static/img/product6.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "129.9元",
							oprice: "159.9元",
							discount: "8.8折"
						},
						{
							id: 7,
							imgUrl: "/static/img/product2.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "29.9元",
							oprice: "59.9元",
							discount: "4.99折"
						},
						{
							id: 8,
							imgUrl: "/static/img/product1.jpg",
							name: "毛绒大衣爆款2022必备不买血亏",
							pprice: "26.9元",
							oprice: "98.9元",
							discount: "3.8折"
						},
						{
							id: 9,
							imgUrl: "/static/img/product3.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "299.9元",
							oprice: "599.9元",
							discount: "2.7折"
						},
						{
							id: 10,
							imgUrl: "/static/img/product4.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "129.9元",
							oprice: "159.9元",
							discount: "8.8折"
						},
						{
							id: 11,
							imgUrl: "/static/img/product5.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "129.9元",
							oprice: "159.9元",
							discount: "8.8折"
						},
						{
							id: 12,
							imgUrl: "/static/img/product6.jpg",
							name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
							pprice: "129.9元",
							oprice: "159.9元",
							discount: "8.8折"
						}
					]
				},
			]
		},

	})
})
router.get('/api/index_list/1/data/2', function(req, res, next) {
	res.json({
		"code": 0,
		"data": [{
			type: "commodityList",
			data: [{
					id: 1,
					imgUrl: "/static/img/product2.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "29.9元",
					oprice: "59.9元",
					discount: "4.99折"
				},
				{
					id: 2,
					imgUrl: "/static/img/product1.jpg",
					name: "毛绒大衣爆款2022必备不买血亏",
					pprice: "26.9元",
					oprice: "98.9元",
					discount: "3.8折"
				},
				{
					id: 3,
					imgUrl: "/static/img/product3.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "299.9元",
					oprice: "599.9元",
					discount: "2.7折"
				},
				{
					id: 4,
					imgUrl: "/static/img/product4.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				},
				{
					id: 5,
					imgUrl: "/static/img/product5.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				},
				{
					id: 6,
					imgUrl: "/static/img/product6.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				}
			]
		}]
	})
});

// 分类数据1
router.get('/api/index_list/2/data/1', function(req, res, next) {
	res.json({
		"code": 0,
		"data": [{
				type: "bannerList",
				imgUrl: "/static/img/swiper1.jpg"
			},
			{
				type: "iconsList",
				data: [{
						imgUrl: "/static/tabbar/me.png",
						name: "运动鞋"
					},
					{
						imgUrl: "/static/tabbar/me-choose.png",
						name: "休闲鞋"
					},
					{
						imgUrl: "/static/tabbar/home.png",
						name: "凉鞋"
					},
					{
						imgUrl: "/static/tabbar/home-choose.png",
						name: "拖鞋"
					},
					{
						imgUrl: "/static/tabbar/cart.png",
						name: "高跟鞋"
					},
					{
						imgUrl: "/static/tabbar/cart-choose.png",
						name: "老爹鞋"
					},
					{
						imgUrl: "/static/tabbar/classify.png",
						name: "老北京布鞋"
					},
					{
						imgUrl: "/static/tabbar/classify-choose.png",
						name: "皮鞋"
					}
				]
			},
			{
				type: "hotList",
				data: [{
						id: 1,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "59.9元",
						discount: "4.99折"
					},
					{
						id: 2,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "26.9元",
						oprice: "98.9元",
						discount: "3.8折"
					},
					{
						id: 3,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "299.9元",
						oprice: "499.9元",
						discount: "2.7折"
					},
					{
						id: 4,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "79.9元",
						discount: "4.99折"
					},
					{
						id: 5,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "126.9元",
						oprice: "198.9元",
						discount: "3.8折"
					},
					{
						id: 6,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "1299.9元",
						oprice: "1599.9元",
						discount: "2.7折"
					}
				]
			},
			{
				type: "shopList",
				data: [{
						bigUrl: "/static/img/swiper3.jpg",
						data: [{
								id: 1,
								imgUrl: "/static/img/product2.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "29.9元",
								oprice: "59.9元",
								discount: "4.99折"
							},
							{
								id: 2,
								imgUrl: "/static/img/product1.jpg",
								name: "毛绒大衣爆款2022必备不买血亏",
								pprice: "26.9元",
								oprice: "98.9元",
								discount: "3.8折"
							},
							{
								id: 3,
								imgUrl: "/static/img/product3.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "299.9元",
								oprice: "599.9元",
								discount: "2.7折"
							},
							{
								id: 4,
								imgUrl: "/static/img/product4.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							},
							{
								id: 5,
								imgUrl: "/static/img/product5.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							}
						]
					},
					{
						bigUrl: "/static/img/swiper1.jpg",
						data: [{
								id: 1,
								imgUrl: "/static/img/product2.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "29.9元",
								oprice: "59.9元",
								discount: "4.99折"
							},
							{
								id: 2,
								imgUrl: "/static/img/product1.jpg",
								name: "毛绒大衣爆款2022必备不买血亏",
								pprice: "26.9元",
								oprice: "98.9元",
								discount: "3.8折"
							},
							{
								id: 3,
								imgUrl: "/static/img/product3.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "299.9元",
								oprice: "599.9元",
								discount: "2.7折"
							},
							{
								id: 4,
								imgUrl: "/static/img/product4.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							},
							{
								id: 5,
								imgUrl: "/static/img/product5.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							}
						]
					}
				]
			},
			{
				type: "commodityList",
				data: [{
						id: 1,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "59.9元",
						discount: "4.99折"
					},
					{
						id: 2,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "26.9元",
						oprice: "98.9元",
						discount: "3.8折"
					},
					{
						id: 3,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "299.9元",
						oprice: "599.9元",
						discount: "2.7折"
					},
					{
						id: 4,
						imgUrl: "/static/img/product4.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 5,
						imgUrl: "/static/img/product5.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 6,
						imgUrl: "/static/img/product6.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 7,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "59.9元",
						discount: "4.99折"
					},
					{
						id: 8,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "26.9元",
						oprice: "98.9元",
						discount: "3.8折"
					},
					{
						id: 9,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "299.9元",
						oprice: "599.9元",
						discount: "2.7折"
					},
					{
						id: 10,
						imgUrl: "/static/img/product4.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 11,
						imgUrl: "/static/img/product5.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 12,
						imgUrl: "/static/img/product6.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					}
				]
			}
		]
	})
});
router.get('/api/index_list/2/data/2', function(req, res, next) {
	res.json({
		"code": 0,
		"data": [{
			type: "commodityList",
			data: [{
					id: 1,
					imgUrl: "/static/img/product2.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "29.9元",
					oprice: "59.9元",
					discount: "4.99折"
				},
				{
					id: 2,
					imgUrl: "/static/img/product1.jpg",
					name: "毛绒大衣爆款2022必备不买血亏",
					pprice: "26.9元",
					oprice: "98.9元",
					discount: "3.8折"
				},
				{
					id: 3,
					imgUrl: "/static/img/product3.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "299.9元",
					oprice: "599.9元",
					discount: "2.7折"
				},
				{
					id: 4,
					imgUrl: "/static/img/product4.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				},
				{
					id: 5,
					imgUrl: "/static/img/product5.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				},
				{
					id: 6,
					imgUrl: "/static/img/product6.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				}
			]
		}]
	})
});
router.get('/api/index_list/2/data/3', function(req, res, next) {
	res.json({
		"code": 0,
		"data": [{
			type: "commodityList",
			data: [{
					id: 1,
					imgUrl: "/static/img/product2.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "29.9元",
					oprice: "59.9元",
					discount: "4.99折"
				},
				{
					id: 2,
					imgUrl: "/static/img/product1.jpg",
					name: "毛绒大衣爆款2022必备不买血亏",
					pprice: "26.9元",
					oprice: "98.9元",
					discount: "3.8折"
				},
				{
					id: 3,
					imgUrl: "/static/img/product3.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "299.9元",
					oprice: "599.9元",
					discount: "2.7折"
				},
				{
					id: 4,
					imgUrl: "/static/img/product4.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				},
				{
					id: 5,
					imgUrl: "/static/img/product5.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				},
				{
					id: 6,
					imgUrl: "/static/img/product6.jpg",
					name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
					pprice: "129.9元",
					oprice: "159.9元",
					discount: "8.8折"
				}
			]
		}]
	})
});

// 分类数据2
router.get('/api/index_list/3/data/1', function(req, res, next) {
	res.json({
		"code": 0,
		"data": [{
				type: "bannerList",
				imgUrl: "/static/img/swiper2.jpg"
			},
			{
				type: "iconsList",
				data: [{
						imgUrl: "/static/tabbar/me.png",
						name: "内衣"
					},
					{
						imgUrl: "/static/tabbar/me-choose.png",
						name: "内裤"
					},
					{
						imgUrl: "/static/tabbar/home.png",
						name: "短袖"
					},
					{
						imgUrl: "/static/tabbar/home-choose.png",
						name: "长袖"
					},
					{
						imgUrl: "/static/tabbar/cart.png",
						name: "长裤"
					},
					{
						imgUrl: "/static/tabbar/cart-choose.png",
						name: "中裤"
					},
					{
						imgUrl: "/static/tabbar/classify.png",
						name: "羽绒服"
					},
					{
						imgUrl: "/static/tabbar/classify-choose.png",
						name: "夹克衫"
					}
				]
			},
			{
				type: "hotList",
				data: [{
						id: 1,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "59.9元",
						discount: "4.99折"
					},
					{
						id: 2,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "26.9元",
						oprice: "98.9元",
						discount: "3.8折"
					},
					{
						id: 3,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "299.9元",
						oprice: "499.9元",
						discount: "2.7折"
					},
					{
						id: 4,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "79.9元",
						discount: "4.99折"
					},
					{
						id: 5,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "126.9元",
						oprice: "198.9元",
						discount: "3.8折"
					},
					{
						id: 6,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "1299.9元",
						oprice: "1599.9元",
						discount: "2.7折"
					}
				]
			},
			{
				type: "shopList",
				data: [{
						bigUrl: "/static/img/swiper3.jpg",
						data: [{
								id: 1,
								imgUrl: "/static/img/product2.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "29.9元",
								oprice: "59.9元",
								discount: "4.99折"
							},
							{
								id: 2,
								imgUrl: "/static/img/product1.jpg",
								name: "毛绒大衣爆款2022必备不买血亏",
								pprice: "26.9元",
								oprice: "98.9元",
								discount: "3.8折"
							},
							{
								id: 3,
								imgUrl: "/static/img/product3.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "299.9元",
								oprice: "599.9元",
								discount: "2.7折"
							},
							{
								id: 4,
								imgUrl: "/static/img/product4.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							},
							{
								id: 5,
								imgUrl: "/static/img/product5.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							}
						]
					},
					{
						bigUrl: "/static/img/swiper1.jpg",
						data: [{
								id: 1,
								imgUrl: "/static/img/product2.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "29.9元",
								oprice: "59.9元",
								discount: "4.99折"
							},
							{
								id: 2,
								imgUrl: "/static/img/product1.jpg",
								name: "毛绒大衣爆款2022必备不买血亏",
								pprice: "26.9元",
								oprice: "98.9元",
								discount: "3.8折"
							},
							{
								id: 3,
								imgUrl: "/static/img/product3.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "299.9元",
								oprice: "599.9元",
								discount: "2.7折"
							},
							{
								id: 4,
								imgUrl: "/static/img/product4.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							},
							{
								id: 5,
								imgUrl: "/static/img/product5.jpg",
								name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
								pprice: "129.9元",
								oprice: "159.9元",
								discount: "8.8折"
							}
						]
					}
				]
			},
			{
				type: "commodityList",
				data: [{
						id: 1,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "59.9元",
						discount: "4.99折"
					},
					{
						id: 2,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "26.9元",
						oprice: "98.9元",
						discount: "3.8折"
					},
					{
						id: 3,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "299.9元",
						oprice: "599.9元",
						discount: "2.7折"
					},
					{
						id: 4,
						imgUrl: "/static/img/product4.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 5,
						imgUrl: "/static/img/product5.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 6,
						imgUrl: "/static/img/product6.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 7,
						imgUrl: "/static/img/product2.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "29.9元",
						oprice: "59.9元",
						discount: "4.99折"
					},
					{
						id: 8,
						imgUrl: "/static/img/product1.jpg",
						name: "毛绒大衣爆款2022必备不买血亏",
						pprice: "26.9元",
						oprice: "98.9元",
						discount: "3.8折"
					},
					{
						id: 9,
						imgUrl: "/static/img/product3.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "299.9元",
						oprice: "599.9元",
						discount: "2.7折"
					},
					{
						id: 10,
						imgUrl: "/static/img/product4.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 11,
						imgUrl: "/static/img/product5.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					},
					{
						id: 12,
						imgUrl: "/static/img/product6.jpg",
						name: "新人0元免费领免费领原生木浆超厚抽纸纸巾纸巾纸巾",
						pprice: "129.9元",
						oprice: "159.9元",
						discount: "8.8折"
					}
				]
			}
		]
	})
});

// 搜索页
router.get("/api/goods/search", function(req, res, next) {
	// 请求示例： /api/goods/search?name=衣服&pprice=desc

	let [goodsName, orderName] = Object.keys(req.query)
	let name = req.query.name
	let order = req.query[orderName]

	connection.query(`select * from goods_search where name like '%${name}%' order by ${orderName} ${order}`,
		function(err, result, fields) {
			if (err) {
				throw Error
			}
			console.log(result)
			res.send({
				code: "0",
				data: result
			})
		})
})

// 分类页
router.get('/api/goods/list', function(req, res, next) {
	res.json({
		code: 0,
		data: [{
				id: 1,
				name: "家居家纺",
				data: [{
						name: "家纺",
						list: [{
								id: 1,
								name: "毛巾/浴巾",
								imgUrl: "/static/img/product1.jpg"
							},
							{
								id: 2,
								name: "枕头",
								imgUrl: "/static/img/product2.jpg"
							},
							{
								id: 3,
								name: "床单",
								imgUrl: "/static/img/product3.jpg"
							}
						]
					},
					{
						name: "生活用品",
						list: [{
								id: 1,
								name: "牙刷",
								imgUrl: "/static/img/product4.jpg"
							},
							{
								id: 2,
								name: "纸巾",
								imgUrl: "/static/img/product5.jpg"
							},
							{
								id: 3,
								name: "电热水壶",
								imgUrl: "/static/img/product6.jpg"
							}
						]
					}
				]
			},
			{
				id: 2,
				name: "女装",
				data: [{
						name: "裙装",
						list: [{
								id: 1,
								name: "半身裙",
								imgUrl: "/static/img/product1.jpg"
							},
							{
								id: 2,
								name: "连衣裙",
								imgUrl: "/static/img/product2.jpg"
							},
							{
								id: 3,
								name: "吊带裙",
								imgUrl: "/static/img/product3.jpg"
							}
						]
					},
					{
						name: "上衣",
						list: [{
								id: 1,
								name: "打底衫",
								imgUrl: "/static/img/product4.jpg"
							},
							{
								id: 2,
								name: "衬衫",
								imgUrl: "/static/img/product5.jpg"
							},
							{
								id: 3,
								name: "针织衫",
								imgUrl: "/static/img/product6.jpg"
							}
						]
					}
				]
			},
			{
				id: 3,
				name: "男装",
				data: [{
						name: "上衣",
						list: [{
								id: 1,
								name: "半身裙",
								imgUrl: "/static/img/product1.jpg"
							},
							{
								id: 2,
								name: "连衣裙",
								imgUrl: "/static/img/product2.jpg"
							},
							{
								id: 3,
								name: "吊带裙",
								imgUrl: "/static/img/product3.jpg"
							}
						]
					},
					{
						name: "裤装",
						list: [{
								id: 1,
								name: "打底衫",
								imgUrl: "/static/img/product4.jpg"
							},
							{
								id: 2,
								name: "衬衫",
								imgUrl: "/static/img/product5.jpg"
							},
							{
								id: 3,
								name: "针织衫",
								imgUrl: "/static/img/product6.jpg"
							}
						]
					}
				]
			}
		]
	})
});

// 详情页
router.get("/api/goods/id", function(req, res, next) {
	let id = req.query.id
	connection.query(`select * from goods_search where id=${id}`, function(err, result, fields) {
		if (err) {
			throw Error
		}
		console.log(result)
		res.send({
			code: "0",
			data: result
		})
	})
})


module.exports = router;
